package com.hjx.windowtool.record;

import java.awt.EventQueue;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;

import javax.swing.JFrame;
import javax.swing.JSplitPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class CameraRecordApp {

	private JFrame frame;
	private JTextField textField;
	private JTextField txt_cameraIndex;
	private JTextField txt_audioIndex;
	private JTextField textField_1;
	private JTextField textField_2;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
					CameraRecordApp window = new CameraRecordApp();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public CameraRecordApp() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setResizeWeight(0.5);
//		splitPane.setResizeWeight(0.5);
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		frame.getContentPane().add(splitPane, BorderLayout.CENTER);
		
		JPanel panel = new JPanel();
		splitPane.setLeftComponent(panel);
		panel.setLayout(null);
		splitPane.addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent e) {
				splitPane.setResizeWeight(125d/(splitPane.getBounds().height*1d));
			}
		});
		
		JLabel label = new JLabel("保存位置");
		label.setBounds(10, 10, 54, 15);
		panel.add(label);
		
		textField = new JTextField();
		textField.setBounds(68, 7, 323, 21);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel label_1 = new JLabel("摄像头");
		label_1.setBounds(10, 35, 54, 15);
		panel.add(label_1);
		
		txt_cameraIndex = new JTextField();
		txt_cameraIndex.setText("0");
		txt_cameraIndex.setBounds(68, 32, 66, 21);
		panel.add(txt_cameraIndex);
		txt_cameraIndex.setColumns(10);
		
		JLabel label_2 = new JLabel("麦克风");
		label_2.setBounds(144, 35, 46, 15);
		panel.add(label_2);
		
		txt_audioIndex = new JTextField();
		txt_audioIndex.setText("4");
		txt_audioIndex.setBounds(200, 32, 66, 21);
		panel.add(txt_audioIndex);
		txt_audioIndex.setColumns(10);
		
		JLabel label_3 = new JLabel("视频宽度");
		label_3.setBounds(10, 60, 54, 15);
		panel.add(label_3);
		
		textField_1 = new JTextField();
		textField_1.setText("0");
		textField_1.setBounds(69, 57, 66, 21);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel label_4 = new JLabel("高度");
		label_4.setBounds(144, 60, 54, 15);
		panel.add(label_4);
		
		textField_2 = new JTextField();
		textField_2.setText("0");
		textField_2.setBounds(200, 57, 66, 21);
		panel.add(textField_2);
		textField_2.setColumns(10);
		
		JButton button = new JButton("录像");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
		button.setBounds(69, 85, 93, 23);
		panel.add(button);
		
		JButton button_1 = new JButton("停止录像");
		button_1.setBounds(173, 85, 93, 23);
		panel.add(button_1);
		
		JPanel panel_image = new JPanel();
		splitPane.setRightComponent(panel_image);
	}
}
